package my1st;

import java.io.*;
import java.util.*;
public class Trywithresources {
    public static void main(String[] args) {
    String line;
        try(BufferedReader br = new BufferedReader(new FileReader("test.txt"))) {
            while ((line = br.readLine()) != null) {
                System.out.println("Line =>"+line);
            }
        } catch (IOException e) {
            System.out.println("IOException in try block =>" + e.getMessage());
        }
        try (Scanner scanner = new Scanner(new File("testRead.txt"));
                PrintWriter writer = new PrintWriter(new File("testWrite.txt"))) {
                while (scanner.hasNext()) {
                    writer.print(scanner.nextLine());
                }
            } catch (IOException e) {
                System.out.println("IOException in try block =>" + e.getMessage());
            }      
    }
}
